package com.qn;

import com.qn.chain2.Handler;
import com.qn.chain2.LeaveRequest;
import com.qn.chain2.impl.GeneralManager;
import com.qn.chain2.impl.GroupLeader;
import com.qn.chain2.impl.Manager;
import lombok.extern.slf4j.Slf4j;
import org.junit.jupiter.api.Test;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.boot.test.context.SpringBootTest;

import java.text.ParseException;

@SpringBootTest
@Slf4j
class Chain2 {
    @Autowired
    @Qualifier("firstHandler")
    private Handler firstHandler;

    @Test
    public void test_AuthLink() throws ParseException {
        //创建一个请假条对象
        LeaveRequest leave = new LeaveRequest("小明",7,"身体不适");

        //创建各级领导对象
        GroupLeader groupLeader = new GroupLeader();
        Manager manager = new Manager();
        GeneralManager generalManager = new GeneralManager();

        //设置处理者链
        groupLeader.setNextHandler(manager);
        manager.setNextHandler(generalManager);


        //小明提交请假申请
        groupLeader.submit(leave);
    }

    @Test
    public void test_AuthLink2() throws ParseException {
        //创建一个请假条对象
        LeaveRequest leave = new LeaveRequest("小明",7,"身体不适");

        //小明提交请假申请

        firstHandler.submit(leave);


    }
}
